#include "CardTypeManager.h"
#include "CardType.h"
#include "CardTypeData.h"
#include "PokerData.h"
#include <iostream>

CardTypeManager::CardTypeManager() {
  HighCard * pHighCard = new HighCard();
  cardTypeList.push_back(pHighCard);

  OnePair * pOnePair = new OnePair();
  cardTypeList.push_back(pOnePair);

  TwoPair * pTwoPair = new TwoPair();
  cardTypeList.push_back(pTwoPair);

  ThreeOfAKind * pThreeOfAKind = new ThreeOfAKind();
  cardTypeList.push_back(pThreeOfAKind);

  Straight * pStraight = new Straight();
  cardTypeList.push_back(pStraight);

  Flush * pFlush = new Flush();
  cardTypeList.push_back(pFlush);

  FullHouse * pFullHouse = new FullHouse();
  cardTypeList.push_back(pFullHouse);

  FourOfAKind * pFourOfAKind = new FourOfAKind();
  cardTypeList.push_back(pFourOfAKind);

  StraightFlush * pStraightFlush = new StraightFlush();
  cardTypeList.push_back(pStraightFlush);

  RoyalStraightFlush * pRoyalStraightFlush = new RoyalStraightFlush();
  cardTypeList.push_back(pRoyalStraightFlush);
}

CardTypeManager::~CardTypeManager() {
}

CardTypeManager * CardTypeManager::sharedCardTypeManager() {
  static CardTypeManager * instance = NULL;
  if (!instance) {
    instance = new CardTypeManager();
  }
  return instance;
}

CardTypeData CardTypeManager::getCardTypeData(const PokerData & data) {
  const CardType * pCardType = getCardType(CardType::RoyalStraightFlush);
  return pCardType->getCardType(data);
}

const CardType * CardTypeManager::getCardType(CardType::Type type) {
  return cardTypeList[type];
}
